package com.leetcode.周赛.第225场;

/**
 * @author: xiaomi
 * @date: 2021/1/24
 * @description: 5661. 替换隐藏数字得到的最晚时间
 * https://leetcode-cn.com/contest/weekly-contest-225/problems/latest-time-by-replacing-hidden-digits/
 */
public class A_5661_替换隐藏数字得到的最晚时间 {

    public static void main(String[] args) {

    }


    /**
     * 每一位数组的最大值
     *
     * @param time
     * @return
     */
    public String maximumTime(String time) {


        char[] chars = time.toCharArray();
        if (chars[0] == '?') {
            //第一位需要考虑第二位
            if (chars[1] == '?' || chars[1] < '4') {
                chars[0] = '2';
            } else {
                chars[0] = '1';
            }

        }
        if (chars[1] == '?') {
            if (chars[0] == '1' || chars[0] == '0') {
                chars[1] = '9';
            } else {
                chars[1] = '3';
            }
        }
        if (chars[3] == '?') {
            chars[3] = '5';
        }
        if (chars[4] == '?') {
            chars[4] = '9';
        }

        return new String(chars);
    }
}
